import { request } from '@/utils/request';
import Api from '@/core/permission/modules/workorder/categary';

export function getCategaryList(data?: API.CategaryFindParams) {
  return request<API.CategaryListResult>({
    url: Api.list,
    method: 'get',
    params: data
  },{
    isGetDataDirectly:true
  });
}

export function getCategaryInfo(query: { menuId: number }) {
  return request<API.CategaryInfoResult>({
    url: Api.info,
    method: 'get',
    params: query,
  });
}

export function createCategary(data: API.CategaryAddParams) {
  return request(
    {
      url: Api.add,
      method: 'POST',
      data,
    },
    {
      successMsg: '创建成功',
    },
  );
}

export function updateCategary(data: API.CategaryUpdateParams) {
  return request(
    {
      url: Api.update,
      method: 'post',
      data,
    },
    {
      successMsg: '更新成功',
    },
  );
}

export function deleteCategary(data: { id: string }) {
  return request(
    {
      url: Api.delete + "/" + data.id,
      method: 'delete',
    },
    {
      successMsg: '删除成功',
    },
  );
}
